<?php

include('../dao/userDAO.php');

function getUserList($start_position, $row_per_page) {
    return loadUsers($start_position, $row_per_page);
}

function sDeleteUser($id) {
    return deleteUser($id);
}

function sAddUser($nick, $name, $accountType, $pass) {
    return addUser($nick, $name, $accountType, $pass);
}

function getNumberOfUser() {
    return countUser();
}

function sUpdateUserInfo($uid, $nick, $name, $accountType, $pass) {
    return updateUserInfo($uid, $nick, $name, $accountType, $pass);
}

function authenticate($username, $password) {
    $result = getUser($username);
    $num = ConnectionManager::getInstance()->getNumRows();

    if ($num > 0) {
        $userRow = ConnectionManager::getInstance()->fetchArray();
        if ($userRow['USER_PASS'] == $password) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}

function getUserByName($userName) {
    return getUser($userName);
}

?>
